#pragma once
#pragma warning(disable:4996)       // disable checked iterator errors http://msdn.microsoft.com/en-us/library/aa985965(VS.80).aspx 

//
// Copyright (C) 2011 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.101

#include <Macros.h>
#include <CoVector.h>
#include <CoMatrix.h>
#include <CoCube.h>
#include <ValueHelpers.h>
#include <Settings.h>

#include <gen/QL/Termstructures/Volatility/Optionlet/OptionletVolatilityStructure.h>
#pragma unmanaged 
#include <ql\termstructures\volatility\optionlet\strippedoptionletadapter.hpp>
#include <boost/smart_ptr/detail/spinlock.hpp>
#pragma managed 

using namespace System;
using namespace QuantLib;
using namespace Cephei;

using namespace Cephei::QL::Times;
using namespace Cephei::QL::Termstructures::Volatility;
#define HANDLE
#undef ABSTRACT
#undef STRUCT
namespace Cephei { namespace QL { namespace Termstructures { namespace Volatility { namespace Optionlet {
	//////////////////////////////////////////////////////////////////////////////////////////////
	// implementation of IStrippedOptionletAdapter
	public ref class CStrippedOptionletAdapter : 
            public COptionletVolatilityStructure,
            public Cephei::QL::Termstructures::Volatility::Optionlet::IStrippedOptionletAdapter
	{
	protected: 
		boost::shared_ptr<QuantLib::StrippedOptionletAdapter>* _ppStrippedOptionletAdapter;
#ifdef HANDLE
		QuantLib::Handle<QuantLib::StrippedOptionletAdapter>* _phStrippedOptionletAdapter;
#endif
		Object^ _StrippedOptionletAdapterOwner;     // reference to object that manages the storage for this object
	internal:
		CStrippedOptionletAdapter (Cephei::QL::Termstructures::Volatility::Optionlet::IStrippedOptionletBase^ s);
        CStrippedOptionletAdapter (boost::shared_ptr<QuantLib::StrippedOptionletAdapter>& childNative, Object^ owner);
        CStrippedOptionletAdapter (QuantLib::StrippedOptionletAdapter& childNative, Object^ owner);
        CStrippedOptionletAdapter (CStrippedOptionletAdapter^ copy);
        CStrippedOptionletAdapter (System::Type^ t);
#ifdef STRUCT
        CStrippedOptionletAdapter (QuantLib::StrippedOptionletAdapter childNative);
#endif       
#ifdef HANDLE
		CStrippedOptionletAdapter (QuantLib::Handle<QuantLib::StrippedOptionletAdapter>& childNative, Object^ owner);
		CStrippedOptionletAdapter (QuantLib::Handle<QuantLib::StrippedOptionletAdapter> childNative);
#endif
		virtual ~CStrippedOptionletAdapter ();
		!CStrippedOptionletAdapter ();

	internal:
		QuantLib::StrippedOptionletAdapter& GetReference ();
		boost::shared_ptr<QuantLib::StrippedOptionletAdapter>& GetShared ();
		QuantLib::StrippedOptionletAdapter* GetPointer ();
        void SetStrippedOptionletAdapter (boost::shared_ptr<QuantLib::StrippedOptionletAdapter> native)
        {
            if (_ppStrippedOptionletAdapter != NULL)
                delete _ppStrippedOptionletAdapter;
            _ppStrippedOptionletAdapter = new boost::shared_ptr<QuantLib::StrippedOptionletAdapter> (native);
            SetOptionletVolatilityStructure (boost::dynamic_pointer_cast<QuantLib::OptionletVolatilityStructure> (*_ppStrippedOptionletAdapter));
        }
#ifdef HANDLE
		QuantLib::Handle<QuantLib::StrippedOptionletAdapter>& GetHandle ();
#endif
		virtual bool HasNative () override;
    public:
        property DateTime MaxDate 
        {
		    virtual DateTime get () ;
        }
        property Double MaxStrike 
        {
		    virtual Double get () ;
        }
        property Double MinStrike 
        {
		    virtual Double get () ;
        }
        property Cephei::QL::Termstructures::Volatility::Optionlet::IStrippedOptionletAdapter^ PerformCalculations 
        {
		    virtual Cephei::QL::Termstructures::Volatility::Optionlet::IStrippedOptionletAdapter^ get () ;
        }
        property Cephei::QL::Termstructures::Volatility::Optionlet::IStrippedOptionletAdapter^ Update 
        {
		    virtual Cephei::QL::Termstructures::Volatility::Optionlet::IStrippedOptionletAdapter^ get () ;
        }
        property Double M1957_MaxStrike 
        {
            virtual Double get () = Cephei::QL::Termstructures::IVolatilityTermStructure::MaxStrike::get
            {
                return ((Cephei::QL::Termstructures::Volatility::Optionlet::IStrippedOptionletAdapter^)this)->MaxStrike;
            }
        }
        property Double M1957_MinStrike 
        {
            virtual Double get () = Cephei::QL::Termstructures::IVolatilityTermStructure::MinStrike::get
            {
                return ((Cephei::QL::Termstructures::Volatility::Optionlet::IStrippedOptionletAdapter^)this)->MinStrike;
            }
        }
        property DateTime M1957_MaxDate 
        {
            virtual DateTime get () = Cephei::QL::ITermStructure::MaxDate::get
            {
                return ((Cephei::QL::Termstructures::Volatility::Optionlet::IStrippedOptionletAdapter^)this)->MaxDate;
            }
        }
        property Cephei::QL::ITermStructure^ M1957_Update 
        {
            virtual Cephei::QL::ITermStructure^ get () = Cephei::QL::ITermStructure::Update::get
            {
                return ((Cephei::QL::Termstructures::Volatility::Optionlet::IStrippedOptionletAdapter^)this)->Update;
            }
        }
    };
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Factory class
	public ref class CStrippedOptionletAdapter_Factory : public System::MarshalByRefObject,  public IStrippedOptionletAdapter_Factory
	{
	public:
        virtual IStrippedOptionletAdapter^ Create (Cephei::QL::Termstructures::Volatility::Optionlet::IStrippedOptionletBase^ s);
    };
   
/*Cephei*/ } /*QL*/ } /*Termstructures*/ } /*Volatility*/ } /*Optionlet */}
